local lhs "cog"
local rhs "hours"
local robust "simple"
local controls "${CONTROLlist_`lhs'}"
local subsample  "$subsample"
local type "het"

qui {
	local cnt=100
	capture program drop ccn_het
	matrix actual_estimates_mat = J(`cnt',6,-9)
	local rowcounter = 0
	forvalues K=1(1)100 {
		noisily display "LHS=`lhs', RHS=`rhs', SE=`robust', K=`K', $S_DATE, $S_TIME"
		local rowcounter = `rowcounter'+1
		use "$datapath/003_cluster_`subsample'_`lhs'.dta", clear
		qui tab X_`K', generate(dumX_`K'_)
		gen A=afqt_mom
		qui ccn_`type' symmetric `K' `rhs' `lhs' `robust' "`controls'" het_tobit
		matrix actual_estimates_mat[`rowcounter',1] = r(BETA)
		matrix actual_estimates_mat[`rowcounter',2] = r(BETA_se)		
		matrix actual_estimates_mat[`rowcounter',3] = r(BETA_A)
		matrix actual_estimates_mat[`rowcounter',4] = r(BETA_A_se)		
		matrix actual_estimates_mat[`rowcounter',5] = r(ESAMP)
		matrix actual_estimates_mat[`rowcounter',6] = `K'
	}
}
mat colnames actual_estimates_mat = b_HetSymm se_HetSymm bA_HetSymm seA_HetSymm Neff_HetSymm Kcluster
clear
qui svmat actual_estimates_mat, names(col)
gen LHS="`lhs'"
gen RHS="`rhs'"
replace b_HetSymm=100*b_HetSymm
replace se_HetSymm=100*se_HetSymm
replace bA_HetSymm=100*bA_HetSymm
replace seA_HetSymm=100*seA_HetSymm
save "$datapath/000_`type'_byK.dta", replace
